﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Lyon.WinForm
{
    /// <summary>
    /// 异常消息提示框。
    /// </summary>
    public class ExceptionMessageBox
    {
        static public DialogResult Show(Exception ex, string text)
        {
            return MessageBox.Show(GetMessage(ex, text));
        }
        static public DialogResult Show(IWin32Window owner, Exception ex, string text)
        {
            return MessageBox.Show(owner, GetMessage(ex, text));
        }

        static public DialogResult Show(Exception ex, string text, string caption)
        {
            return MessageBox.Show(GetMessage(ex, text), caption);
        }
        static public DialogResult Show(IWin32Window owner, Exception ex, string text, string caption)
        {
            return MessageBox.Show(owner, GetMessage(ex, text), caption);
        }

        static public DialogResult Show(Exception ex, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            return MessageBox.Show(GetMessage(ex, text), caption, buttons, icon);
        }
        static public DialogResult Show(IWin32Window owner, Exception ex, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            return MessageBox.Show(owner, GetMessage(ex, text), caption, buttons, icon);
        }

        static string GetMessage(Exception ex, string text)
        {
            return String.Format("{0}{2}{2}异常信息：{2}{1}", text, ex, Environment.NewLine);
        }
    }
}
